package com.da.javatest.niuke.baodian;

/**
 * @author chenlida
 * @date 2020/10/12 17:16
 * https://www.nowcoder.com/practice/e1bb714eb9924188a0d5a6df2216a3d1?tpId=8&tags=&title=&diffculty=0&judgeStatus=0&rp=1
 */
public class C62Board {
    public boolean checkWon(int[][] board) {
        int length = board[0].length;
        // 横排
        for (int i = 0; i < length; i++) {
            for (int j = 0; j < length; j++) {
                if (board[i][j] != 1) {
                    break;
                }
                if (j == length - 1) {
                    return true;
                }
            }
        }
        // 竖排
        for (int i = 0; i < length; i++) {
            for (int j = 0; j < length; j++) {
                if (board[j][i] != 1) {
                    break;
                }
                if (j == length - 1) {
                    return true;
                }
            }
        }
        // 斜排
        for (int i = 0; i < length; i++) {
            if (board[i][i] != 1) {
                break;
            }
            if (i == length - 1) {
                return true;
            }
        }
        return false;
    }
}
